<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>商品维护</title>
    <script type="text/javascript" src="<c:url value='/static/js/admin/product/list.js' />"></script>
</head>

<body>
<c:if test="${!empty param.msg}">
	<div class="alert alert-green fadein-top"><span class="close rotate-hover"></span><strong>提示：</strong>${param.msg}</div>
</c:if>
<form id="form" method="post" action="<c:url value='/admin/product/list' />" name="form">
<div class="panel admin-panel">
	<div class="panel-head"><strong>商品列表</strong></div>
    <div class="padding border-bottom">
      	<div class="line">
	       	<div class="x4">
		        <input type="button" class="button button-small checkall" name="checkall" checkfor="id" value="全选" />
		        <input onclick="locationHref('<c:url value='/admin/product/edit' />')" type="button" class="button button-small border-green" value="添加商品" />
		        <input onclick="deleteByIds()" type="button" class="button button-small border-yellow" value="批量删除" />
		        <button type="button" class="button button-small bg-main dialogs" data-toggle="click" data-target="#mydialog" data-mask="1" data-width="50%">批量导入</button>
	    	</div>
	    	<div class="x5"></div>
	    	<div class="x3">
	   			<div class="input-group padding-little-top"> 
	   				<input type="text" class="input input-small border-main" name="productName" value="${product.productName}" placeholder="请输入：商品名称" /> 
	   				<span class="addbtn"><button type="submit" class="button input-small bg-main">筛选</button></span> 
	   			</div>
	    	</div>
    	</div>
    </div>
    <table class="table table-hover">
       	<tr>
        	<th width="45">选择</th>
        	<th width="100">展示图片</th>
        	<th width="*">商品名称</th>
        	<th width="70">零售价</th>
        	<th width="70">预售价</th>
        	<th width="70">库存</th>
        	<th width="50">
        		<div class="field"> 
				<select style="width: 60px;" name="status" onchange="javascript:this.form.submit();">
					<option value="-1" <c:if test="${status == -1 }">selected="selected"</c:if>>状态</option>
    				<option value="1" <c:if test="${status == 1 }">selected="selected"</c:if>>上架</option>
    				<option value="0" <c:if test="${status == 0 }">selected="selected"</c:if>>下架</option>
				</select>
				</div>
        	</th>
        	<th width="100">下架时间</th>
        	<th width="180">操作</th>
       	</tr>
       	<c:forEach items="${pager.datas}" var="pd">
       		<tr>
       			<td><input type="checkbox" name="id" value="${pd.id}" /></td>
       			<td><img src="<c:url value="${pd.image1}"/>" width="40" height="40"/></td>
       			<td>${pd.productName}</td>
       			<td>${pd.marketPrice}</td>
       			<td>${pd.salesPrice}</td>
       			<td>${pd.stock}</td>
       			<td>
	       			<c:if test="${pd.state == 0 }">下架</c:if>
					<c:if test="${pd.state == 1 }">上架</c:if>
       			</td>
       			<td>
       				<fmt:formatDate value="${pd.closeTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
       			</td>
       			<td>
       				<a class="button border-green button-little" href="<c:url value='/admin/product/onTop?id=${pd.id}' />">刷新</a>
       				<a class="button border-red button-little" href="javascript:location.href='<c:url value='/admin/product/updateState?id=${pd.id}' />'">
       					<c:if test="${pd.state == 0 }">上架</c:if>
						<c:if test="${pd.state == 1 }">下架</c:if>
       				</a>
        			<a class="button border-blue button-little" href="<c:url value='/admin/product/edit?id=${pd.id}' />">修改</a>
        			<a class="button border-yellow button-little" href="javascript:void(0);" onclick="deleteById('${pd.id}')">删除</a>
       			</td>
       		</tr>
       	</c:forEach>
    </table>
	  <jsp:include page="../../commons/pager.jsp">
	    	<jsp:param value="list" name="url"/>
	  </jsp:include>
</div>
</form>
<div id="mydialog">
    <form action="<c:url value='/admin/product/import' />" method="post" enctype="multipart/form-data">
	<div class="dialog">
		<div class="dialog-head">
			<span class="close rotate-hover"></span>
			<strong>对话框标题</strong>
		</div>
		<div class="dialog-body"> <input type="file" name="file"> </div>
		<div class="dialog-foot">
			<button class="button dialog-close">取消</button>
			<button type="submit" class="button bg-green">确认</button>
		</div>
	</div>
	</form>
</div>
</body>
</html>